// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers.  See the top-level LICENSE file for dates and other
// details.  No copyright assignment is required to contribute to VisIt.

#include <PySliceAttributes.h>
#include <ObserverToCallback.h>
#include <stdio.h>
#include <Py2and3Support.h>

// ****************************************************************************
// Module: PySliceAttributes
//
// Purpose:
//   This class contains attributes for the arbitrary slice.
//
// Note:       Autogenerated by xml2python. Do not modify by hand!
//
// Programmer: xml2python
// Creation:   omitted
//
// ****************************************************************************

//
// This struct contains the Python type information and a SliceAttributes.
//
struct SliceAttributesObject
{
    PyObject_HEAD
    SliceAttributes *data;
    bool        owns;
    PyObject   *parent;
};

//
// Internal prototypes
//
static PyObject *NewSliceAttributes(int);
std::string
PySliceAttributes_ToString(const SliceAttributes *atts, const char *prefix, const bool forLogging)
{
    std::string str;
    char tmpStr[1000];

    const char *originType_names = "Point, Intercept, Percent, Zone, Node";
    switch (atts->GetOriginType())
    {
      case SliceAttributes::Point:
          snprintf(tmpStr, 1000, "%soriginType = %sPoint  # %s\n", prefix, prefix, originType_names);
          str += tmpStr;
          break;
      case SliceAttributes::Intercept:
          snprintf(tmpStr, 1000, "%soriginType = %sIntercept  # %s\n", prefix, prefix, originType_names);
          str += tmpStr;
          break;
      case SliceAttributes::Percent:
          snprintf(tmpStr, 1000, "%soriginType = %sPercent  # %s\n", prefix, prefix, originType_names);
          str += tmpStr;
          break;
      case SliceAttributes::Zone:
          snprintf(tmpStr, 1000, "%soriginType = %sZone  # %s\n", prefix, prefix, originType_names);
          str += tmpStr;
          break;
      case SliceAttributes::Node:
          snprintf(tmpStr, 1000, "%soriginType = %sNode  # %s\n", prefix, prefix, originType_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    {   const double *originPoint = atts->GetOriginPoint();
        snprintf(tmpStr, 1000, "%soriginPoint = (", prefix);
        str += tmpStr;
        for(int i = 0; i < 3; ++i)
        {
            snprintf(tmpStr, 1000, "%g", originPoint[i]);
            str += tmpStr;
            if(i < 2)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    snprintf(tmpStr, 1000, "%soriginIntercept = %g\n", prefix, atts->GetOriginIntercept());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%soriginPercent = %g\n", prefix, atts->GetOriginPercent());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%soriginZone = %d\n", prefix, atts->GetOriginZone());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%soriginNode = %d\n", prefix, atts->GetOriginNode());
    str += tmpStr;
    {   const double *normal = atts->GetNormal();
        snprintf(tmpStr, 1000, "%snormal = (", prefix);
        str += tmpStr;
        for(int i = 0; i < 3; ++i)
        {
            snprintf(tmpStr, 1000, "%g", normal[i]);
            str += tmpStr;
            if(i < 2)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    const char *axisType_names = "XAxis, YAxis, ZAxis, Arbitrary, ThetaPhi";
    switch (atts->GetAxisType())
    {
      case SliceAttributes::XAxis:
          snprintf(tmpStr, 1000, "%saxisType = %sXAxis  # %s\n", prefix, prefix, axisType_names);
          str += tmpStr;
          break;
      case SliceAttributes::YAxis:
          snprintf(tmpStr, 1000, "%saxisType = %sYAxis  # %s\n", prefix, prefix, axisType_names);
          str += tmpStr;
          break;
      case SliceAttributes::ZAxis:
          snprintf(tmpStr, 1000, "%saxisType = %sZAxis  # %s\n", prefix, prefix, axisType_names);
          str += tmpStr;
          break;
      case SliceAttributes::Arbitrary:
          snprintf(tmpStr, 1000, "%saxisType = %sArbitrary  # %s\n", prefix, prefix, axisType_names);
          str += tmpStr;
          break;
      case SliceAttributes::ThetaPhi:
          snprintf(tmpStr, 1000, "%saxisType = %sThetaPhi  # %s\n", prefix, prefix, axisType_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    {   const double *upAxis = atts->GetUpAxis();
        snprintf(tmpStr, 1000, "%supAxis = (", prefix);
        str += tmpStr;
        for(int i = 0; i < 3; ++i)
        {
            snprintf(tmpStr, 1000, "%g", upAxis[i]);
            str += tmpStr;
            if(i < 2)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    if(atts->GetProject2d())
        snprintf(tmpStr, 1000, "%sproject2d = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sproject2d = 0\n", prefix);
    str += tmpStr;
    if(atts->GetInteractive())
        snprintf(tmpStr, 1000, "%sinteractive = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sinteractive = 0\n", prefix);
    str += tmpStr;
    if(atts->GetFlip())
        snprintf(tmpStr, 1000, "%sflip = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sflip = 0\n", prefix);
    str += tmpStr;
    snprintf(tmpStr, 1000, "%soriginZoneDomain = %d\n", prefix, atts->GetOriginZoneDomain());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%soriginNodeDomain = %d\n", prefix, atts->GetOriginNodeDomain());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%smeshName = \"%s\"\n", prefix, atts->GetMeshName().c_str());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%stheta = %g\n", prefix, atts->GetTheta());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%sphi = %g\n", prefix, atts->GetPhi());
    str += tmpStr;
    return str;
}

static PyObject *
SliceAttributes_Notify(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;
    obj->data->Notify();
    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SliceAttributes_SetOriginType(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 5)
    {
        std::stringstream ss;
        ss << "An invalid originType value was given." << std::endl;
        ss << "Valid values are in the range [0,4]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " Point";
        ss << ", Intercept";
        ss << ", Percent";
        ss << ", Zone";
        ss << ", Node";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the originType in the object.
    obj->data->SetOriginType(SliceAttributes::OriginType(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SliceAttributes_GetOriginType(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetOriginType()));
    return retval;
}

/*static*/ PyObject *
SliceAttributes_SetOriginPoint(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;

    PyObject *packaged_args = 0;
    double *vals = obj->data->GetOriginPoint();

    if (!PySequence_Check(args) || PyUnicode_Check(args))
        return PyErr_Format(PyExc_TypeError, "Expecting a sequence of numeric args");

    // break open args seq. if we think it matches this API's needs
    if (PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PySequence_Check(packaged_args) && !PyUnicode_Check(packaged_args) &&
            PySequence_Size(packaged_args) == 3)
            args = packaged_args;
    }

    if (PySequence_Size(args) != 3)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "Expecting 3 numeric args");
    }

    for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
    {
        PyObject *item = PySequence_GetItem(args, i);

        if (!PyNumber_Check(item))
        {
            Py_DECREF(item);
            Py_XDECREF(packaged_args);
            return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
        }

        double val = PyFloat_AsDouble(item);
        double cval = double(val);

        if (val == -1 && PyErr_Occurred())
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ double", (int) i);
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ double", (int) i);
        }
        Py_DECREF(item);

        vals[i] = cval;
    }

    Py_XDECREF(packaged_args);

    // Mark the originPoint in the object as modified.
    obj->data->SelectOriginPoint();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SliceAttributes_GetOriginPoint(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the originPoint.
    PyObject *retval = PyTuple_New(3);
    const double *originPoint = obj->data->GetOriginPoint();
    for(int i = 0; i < 3; ++i)
        PyTuple_SET_ITEM(retval, i, PyFloat_FromDouble(originPoint[i]));
    return retval;
}

/*static*/ PyObject *
SliceAttributes_SetOriginIntercept(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the originIntercept in the object.
    obj->data->SetOriginIntercept(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SliceAttributes_GetOriginIntercept(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetOriginIntercept());
    return retval;
}

/*static*/ PyObject *
SliceAttributes_SetOriginPercent(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the originPercent in the object.
    obj->data->SetOriginPercent(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SliceAttributes_GetOriginPercent(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetOriginPercent());
    return retval;
}

/*static*/ PyObject *
SliceAttributes_SetOriginZone(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the originZone in the object.
    obj->data->SetOriginZone(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SliceAttributes_GetOriginZone(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetOriginZone()));
    return retval;
}

/*static*/ PyObject *
SliceAttributes_SetOriginNode(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the originNode in the object.
    obj->data->SetOriginNode(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SliceAttributes_GetOriginNode(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetOriginNode()));
    return retval;
}

/*static*/ PyObject *
SliceAttributes_SetNormal(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;

    PyObject *packaged_args = 0;
    double *vals = obj->data->GetNormal();

    if (!PySequence_Check(args) || PyUnicode_Check(args))
        return PyErr_Format(PyExc_TypeError, "Expecting a sequence of numeric args");

    // break open args seq. if we think it matches this API's needs
    if (PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PySequence_Check(packaged_args) && !PyUnicode_Check(packaged_args) &&
            PySequence_Size(packaged_args) == 3)
            args = packaged_args;
    }

    if (PySequence_Size(args) != 3)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "Expecting 3 numeric args");
    }

    for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
    {
        PyObject *item = PySequence_GetItem(args, i);

        if (!PyNumber_Check(item))
        {
            Py_DECREF(item);
            Py_XDECREF(packaged_args);
            return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
        }

        double val = PyFloat_AsDouble(item);
        double cval = double(val);

        if (val == -1 && PyErr_Occurred())
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ double", (int) i);
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ double", (int) i);
        }
        Py_DECREF(item);

        vals[i] = cval;
    }

    Py_XDECREF(packaged_args);

    // Mark the normal in the object as modified.
    obj->data->SelectNormal();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SliceAttributes_GetNormal(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the normal.
    PyObject *retval = PyTuple_New(3);
    const double *normal = obj->data->GetNormal();
    for(int i = 0; i < 3; ++i)
        PyTuple_SET_ITEM(retval, i, PyFloat_FromDouble(normal[i]));
    return retval;
}

/*static*/ PyObject *
SliceAttributes_SetAxisType(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 5)
    {
        std::stringstream ss;
        ss << "An invalid axisType value was given." << std::endl;
        ss << "Valid values are in the range [0,4]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " XAxis";
        ss << ", YAxis";
        ss << ", ZAxis";
        ss << ", Arbitrary";
        ss << ", ThetaPhi";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the axisType in the object.
    obj->data->SetAxisType(SliceAttributes::AxisType(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SliceAttributes_GetAxisType(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetAxisType()));
    return retval;
}

/*static*/ PyObject *
SliceAttributes_SetUpAxis(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;

    PyObject *packaged_args = 0;
    double *vals = obj->data->GetUpAxis();

    if (!PySequence_Check(args) || PyUnicode_Check(args))
        return PyErr_Format(PyExc_TypeError, "Expecting a sequence of numeric args");

    // break open args seq. if we think it matches this API's needs
    if (PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PySequence_Check(packaged_args) && !PyUnicode_Check(packaged_args) &&
            PySequence_Size(packaged_args) == 3)
            args = packaged_args;
    }

    if (PySequence_Size(args) != 3)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "Expecting 3 numeric args");
    }

    for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
    {
        PyObject *item = PySequence_GetItem(args, i);

        if (!PyNumber_Check(item))
        {
            Py_DECREF(item);
            Py_XDECREF(packaged_args);
            return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
        }

        double val = PyFloat_AsDouble(item);
        double cval = double(val);

        if (val == -1 && PyErr_Occurred())
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ double", (int) i);
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
        {
            Py_XDECREF(packaged_args);
            Py_DECREF(item);
            return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ double", (int) i);
        }
        Py_DECREF(item);

        vals[i] = cval;
    }

    Py_XDECREF(packaged_args);

    // Mark the upAxis in the object as modified.
    obj->data->SelectUpAxis();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SliceAttributes_GetUpAxis(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the upAxis.
    PyObject *retval = PyTuple_New(3);
    const double *upAxis = obj->data->GetUpAxis();
    for(int i = 0; i < 3; ++i)
        PyTuple_SET_ITEM(retval, i, PyFloat_FromDouble(upAxis[i]));
    return retval;
}

/*static*/ PyObject *
SliceAttributes_SetProject2d(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the project2d in the object.
    obj->data->SetProject2d(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SliceAttributes_GetProject2d(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetProject2d()?1L:0L);
    return retval;
}

/*static*/ PyObject *
SliceAttributes_SetInteractive(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the interactive in the object.
    obj->data->SetInteractive(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SliceAttributes_GetInteractive(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetInteractive()?1L:0L);
    return retval;
}

/*static*/ PyObject *
SliceAttributes_SetFlip(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the flip in the object.
    obj->data->SetFlip(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SliceAttributes_GetFlip(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetFlip()?1L:0L);
    return retval;
}

/*static*/ PyObject *
SliceAttributes_SetOriginZoneDomain(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the originZoneDomain in the object.
    obj->data->SetOriginZoneDomain(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SliceAttributes_GetOriginZoneDomain(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetOriginZoneDomain()));
    return retval;
}

/*static*/ PyObject *
SliceAttributes_SetOriginNodeDomain(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the originNodeDomain in the object.
    obj->data->SetOriginNodeDomain(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SliceAttributes_GetOriginNodeDomain(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetOriginNodeDomain()));
    return retval;
}

/*static*/ PyObject *
SliceAttributes_SetMeshName(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged as first member of a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyUnicode_Check(packaged_args))
            args = packaged_args;
    }

    if (!PyUnicode_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a unicode string");
    }

    char const *val = PyUnicode_AsUTF8(args);
    std::string cval = std::string(val);

    if (val == 0 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as utf8 string");
    }

    Py_XDECREF(packaged_args);

    // Set the meshName in the object.
    obj->data->SetMeshName(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SliceAttributes_GetMeshName(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;
    PyObject *retval = PyString_FromString(obj->data->GetMeshName().c_str());
    return retval;
}

/*static*/ PyObject *
SliceAttributes_SetTheta(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the theta in the object.
    obj->data->SetTheta(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SliceAttributes_GetTheta(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetTheta());
    return retval;
}

/*static*/ PyObject *
SliceAttributes_SetPhi(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the phi in the object.
    obj->data->SetPhi(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
SliceAttributes_GetPhi(PyObject *self, PyObject *args)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetPhi());
    return retval;
}



PyMethodDef PySliceAttributes_methods[SLICEATTRIBUTES_NMETH] = {
    {"Notify", SliceAttributes_Notify, METH_VARARGS},
    {"SetOriginType", SliceAttributes_SetOriginType, METH_VARARGS},
    {"GetOriginType", SliceAttributes_GetOriginType, METH_VARARGS},
    {"SetOriginPoint", SliceAttributes_SetOriginPoint, METH_VARARGS},
    {"GetOriginPoint", SliceAttributes_GetOriginPoint, METH_VARARGS},
    {"SetOriginIntercept", SliceAttributes_SetOriginIntercept, METH_VARARGS},
    {"GetOriginIntercept", SliceAttributes_GetOriginIntercept, METH_VARARGS},
    {"SetOriginPercent", SliceAttributes_SetOriginPercent, METH_VARARGS},
    {"GetOriginPercent", SliceAttributes_GetOriginPercent, METH_VARARGS},
    {"SetOriginZone", SliceAttributes_SetOriginZone, METH_VARARGS},
    {"GetOriginZone", SliceAttributes_GetOriginZone, METH_VARARGS},
    {"SetOriginNode", SliceAttributes_SetOriginNode, METH_VARARGS},
    {"GetOriginNode", SliceAttributes_GetOriginNode, METH_VARARGS},
    {"SetNormal", SliceAttributes_SetNormal, METH_VARARGS},
    {"GetNormal", SliceAttributes_GetNormal, METH_VARARGS},
    {"SetAxisType", SliceAttributes_SetAxisType, METH_VARARGS},
    {"GetAxisType", SliceAttributes_GetAxisType, METH_VARARGS},
    {"SetUpAxis", SliceAttributes_SetUpAxis, METH_VARARGS},
    {"GetUpAxis", SliceAttributes_GetUpAxis, METH_VARARGS},
    {"SetProject2d", SliceAttributes_SetProject2d, METH_VARARGS},
    {"GetProject2d", SliceAttributes_GetProject2d, METH_VARARGS},
    {"SetInteractive", SliceAttributes_SetInteractive, METH_VARARGS},
    {"GetInteractive", SliceAttributes_GetInteractive, METH_VARARGS},
    {"SetFlip", SliceAttributes_SetFlip, METH_VARARGS},
    {"GetFlip", SliceAttributes_GetFlip, METH_VARARGS},
    {"SetOriginZoneDomain", SliceAttributes_SetOriginZoneDomain, METH_VARARGS},
    {"GetOriginZoneDomain", SliceAttributes_GetOriginZoneDomain, METH_VARARGS},
    {"SetOriginNodeDomain", SliceAttributes_SetOriginNodeDomain, METH_VARARGS},
    {"GetOriginNodeDomain", SliceAttributes_GetOriginNodeDomain, METH_VARARGS},
    {"SetMeshName", SliceAttributes_SetMeshName, METH_VARARGS},
    {"GetMeshName", SliceAttributes_GetMeshName, METH_VARARGS},
    {"SetTheta", SliceAttributes_SetTheta, METH_VARARGS},
    {"GetTheta", SliceAttributes_GetTheta, METH_VARARGS},
    {"SetPhi", SliceAttributes_SetPhi, METH_VARARGS},
    {"GetPhi", SliceAttributes_GetPhi, METH_VARARGS},
    {NULL, NULL}
};

//
// Type functions
//

static void
SliceAttributes_dealloc(PyObject *v)
{
   SliceAttributesObject *obj = (SliceAttributesObject *)v;
   if(obj->parent != 0)
       Py_DECREF(obj->parent);
   if(obj->owns)
       delete obj->data;
}

static PyObject *SliceAttributes_richcompare(PyObject *self, PyObject *other, int op);
PyObject *
PySliceAttributes_getattr(PyObject *self, char *name)
{
    if(strcmp(name, "originType") == 0)
        return SliceAttributes_GetOriginType(self, NULL);
    if(strcmp(name, "Point") == 0)
        return PyInt_FromLong(long(SliceAttributes::Point));
    if(strcmp(name, "Intercept") == 0)
        return PyInt_FromLong(long(SliceAttributes::Intercept));
    if(strcmp(name, "Percent") == 0)
        return PyInt_FromLong(long(SliceAttributes::Percent));
    if(strcmp(name, "Zone") == 0)
        return PyInt_FromLong(long(SliceAttributes::Zone));
    if(strcmp(name, "Node") == 0)
        return PyInt_FromLong(long(SliceAttributes::Node));

    if(strcmp(name, "originPoint") == 0)
        return SliceAttributes_GetOriginPoint(self, NULL);
    if(strcmp(name, "originIntercept") == 0)
        return SliceAttributes_GetOriginIntercept(self, NULL);
    if(strcmp(name, "originPercent") == 0)
        return SliceAttributes_GetOriginPercent(self, NULL);
    if(strcmp(name, "originZone") == 0)
        return SliceAttributes_GetOriginZone(self, NULL);
    if(strcmp(name, "originNode") == 0)
        return SliceAttributes_GetOriginNode(self, NULL);
    if(strcmp(name, "normal") == 0)
        return SliceAttributes_GetNormal(self, NULL);
    if(strcmp(name, "axisType") == 0)
        return SliceAttributes_GetAxisType(self, NULL);
    if(strcmp(name, "XAxis") == 0)
        return PyInt_FromLong(long(SliceAttributes::XAxis));
    if(strcmp(name, "YAxis") == 0)
        return PyInt_FromLong(long(SliceAttributes::YAxis));
    if(strcmp(name, "ZAxis") == 0)
        return PyInt_FromLong(long(SliceAttributes::ZAxis));
    if(strcmp(name, "Arbitrary") == 0)
        return PyInt_FromLong(long(SliceAttributes::Arbitrary));
    if(strcmp(name, "ThetaPhi") == 0)
        return PyInt_FromLong(long(SliceAttributes::ThetaPhi));

    if(strcmp(name, "upAxis") == 0)
        return SliceAttributes_GetUpAxis(self, NULL);
    if(strcmp(name, "project2d") == 0)
        return SliceAttributes_GetProject2d(self, NULL);
    if(strcmp(name, "interactive") == 0)
        return SliceAttributes_GetInteractive(self, NULL);
    if(strcmp(name, "flip") == 0)
        return SliceAttributes_GetFlip(self, NULL);
    if(strcmp(name, "originZoneDomain") == 0)
        return SliceAttributes_GetOriginZoneDomain(self, NULL);
    if(strcmp(name, "originNodeDomain") == 0)
        return SliceAttributes_GetOriginNodeDomain(self, NULL);
    if(strcmp(name, "meshName") == 0)
        return SliceAttributes_GetMeshName(self, NULL);
    if(strcmp(name, "theta") == 0)
        return SliceAttributes_GetTheta(self, NULL);
    if(strcmp(name, "phi") == 0)
        return SliceAttributes_GetPhi(self, NULL);


    // Add a __dict__ answer so that dir() works
    if (!strcmp(name, "__dict__"))
    {
        PyObject *result = PyDict_New();
        for (int i = 0; PySliceAttributes_methods[i].ml_meth; i++)
            PyDict_SetItem(result,
                PyString_FromString(PySliceAttributes_methods[i].ml_name),
                PyString_FromString(PySliceAttributes_methods[i].ml_name));
        return result;
    }

    return Py_FindMethod(PySliceAttributes_methods, self, name);
}

int
PySliceAttributes_setattr(PyObject *self, char *name, PyObject *args)
{
    PyObject NULL_PY_OBJ;
    PyObject *obj = &NULL_PY_OBJ;

    if(strcmp(name, "originType") == 0)
        obj = SliceAttributes_SetOriginType(self, args);
    else if(strcmp(name, "originPoint") == 0)
        obj = SliceAttributes_SetOriginPoint(self, args);
    else if(strcmp(name, "originIntercept") == 0)
        obj = SliceAttributes_SetOriginIntercept(self, args);
    else if(strcmp(name, "originPercent") == 0)
        obj = SliceAttributes_SetOriginPercent(self, args);
    else if(strcmp(name, "originZone") == 0)
        obj = SliceAttributes_SetOriginZone(self, args);
    else if(strcmp(name, "originNode") == 0)
        obj = SliceAttributes_SetOriginNode(self, args);
    else if(strcmp(name, "normal") == 0)
        obj = SliceAttributes_SetNormal(self, args);
    else if(strcmp(name, "axisType") == 0)
        obj = SliceAttributes_SetAxisType(self, args);
    else if(strcmp(name, "upAxis") == 0)
        obj = SliceAttributes_SetUpAxis(self, args);
    else if(strcmp(name, "project2d") == 0)
        obj = SliceAttributes_SetProject2d(self, args);
    else if(strcmp(name, "interactive") == 0)
        obj = SliceAttributes_SetInteractive(self, args);
    else if(strcmp(name, "flip") == 0)
        obj = SliceAttributes_SetFlip(self, args);
    else if(strcmp(name, "originZoneDomain") == 0)
        obj = SliceAttributes_SetOriginZoneDomain(self, args);
    else if(strcmp(name, "originNodeDomain") == 0)
        obj = SliceAttributes_SetOriginNodeDomain(self, args);
    else if(strcmp(name, "meshName") == 0)
        obj = SliceAttributes_SetMeshName(self, args);
    else if(strcmp(name, "theta") == 0)
        obj = SliceAttributes_SetTheta(self, args);
    else if(strcmp(name, "phi") == 0)
        obj = SliceAttributes_SetPhi(self, args);

    if (obj != NULL && obj != &NULL_PY_OBJ)
        Py_DECREF(obj);

    if (obj == &NULL_PY_OBJ)
    {
        obj = NULL;
        PyErr_Format(PyExc_NameError, "name '%s' is not defined", name);
    }
    else if (obj == NULL && !PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "unknown problem with '%s'", name);

    return (obj != NULL) ? 0 : -1;
}

static int
SliceAttributes_print(PyObject *v, FILE *fp, int flags)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)v;
    fprintf(fp, "%s", PySliceAttributes_ToString(obj->data, "",false).c_str());
    return 0;
}

PyObject *
SliceAttributes_str(PyObject *v)
{
    SliceAttributesObject *obj = (SliceAttributesObject *)v;
    return PyString_FromString(PySliceAttributes_ToString(obj->data,"", false).c_str());
}

//
// The doc string for the class.
//
#if PY_MAJOR_VERSION > 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 5)
static const char *SliceAttributes_Purpose = "This class contains attributes for the arbitrary slice.";
#else
static char *SliceAttributes_Purpose = "This class contains attributes for the arbitrary slice.";
#endif

//
// Python Type Struct Def Macro from Py2and3Support.h
//
//         VISIT_PY_TYPE_OBJ( VPY_TYPE,
//                            VPY_NAME,
//                            VPY_OBJECT,
//                            VPY_DEALLOC,
//                            VPY_PRINT,
//                            VPY_GETATTR,
//                            VPY_SETATTR,
//                            VPY_STR,
//                            VPY_PURPOSE,
//                            VPY_RICHCOMP,
//                            VPY_AS_NUMBER)

//
// The type description structure
//

VISIT_PY_TYPE_OBJ(SliceAttributesType,         \
                  "SliceAttributes",           \
                  SliceAttributesObject,       \
                  SliceAttributes_dealloc,     \
                  SliceAttributes_print,       \
                  PySliceAttributes_getattr,   \
                  PySliceAttributes_setattr,   \
                  SliceAttributes_str,         \
                  SliceAttributes_Purpose,     \
                  SliceAttributes_richcompare, \
                  0); /* as_number*/

//
// Helper function for comparing.
//
static PyObject *
SliceAttributes_richcompare(PyObject *self, PyObject *other, int op)
{
    // only compare against the same type 
    if ( Py_TYPE(self) != &SliceAttributesType
         || Py_TYPE(other) != &SliceAttributesType)
    {
        Py_INCREF(Py_NotImplemented);
        return Py_NotImplemented;
    }

    PyObject *res = NULL;
    SliceAttributes *a = ((SliceAttributesObject *)self)->data;
    SliceAttributes *b = ((SliceAttributesObject *)other)->data;

    switch (op)
    {
       case Py_EQ:
           res = (*a == *b) ? Py_True : Py_False;
           break;
       case Py_NE:
           res = (*a != *b) ? Py_True : Py_False;
           break;
       default:
           res = Py_NotImplemented;
           break;
    }

    Py_INCREF(res);
    return res;
}

//
// Helper functions for object allocation.
//

static SliceAttributes *defaultAtts = 0;
static SliceAttributes *currentAtts = 0;

static PyObject *
NewSliceAttributes(int useCurrent)
{
    SliceAttributesObject *newObject;
    newObject = PyObject_NEW(SliceAttributesObject, &SliceAttributesType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new SliceAttributes(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new SliceAttributes(*defaultAtts);
    else
        newObject->data = new SliceAttributes;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

static PyObject *
WrapSliceAttributes(const SliceAttributes *attr)
{
    SliceAttributesObject *newObject;
    newObject = PyObject_NEW(SliceAttributesObject, &SliceAttributesType);
    if(newObject == NULL)
        return NULL;
    newObject->data = (SliceAttributes *)attr;
    newObject->owns = false;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

///////////////////////////////////////////////////////////////////////////////
//
// Interface that is exposed to the VisIt module.
//
///////////////////////////////////////////////////////////////////////////////

PyObject *
SliceAttributes_new(PyObject *self, PyObject *args)
{
    int useCurrent = 0;
    if (!PyArg_ParseTuple(args, "i", &useCurrent))
    {
        if (!PyArg_ParseTuple(args, ""))
            return NULL;
        else
            PyErr_Clear();
    }

    return (PyObject *)NewSliceAttributes(useCurrent);
}

//
// Plugin method table. These methods are added to the visitmodule's methods.
//
static PyMethodDef SliceAttributesMethods[] = {
    {"SliceAttributes", SliceAttributes_new, METH_VARARGS},
    {NULL,      NULL}        /* Sentinel */
};

static Observer *SliceAttributesObserver = 0;

std::string
PySliceAttributes_GetLogString()
{
    std::string s("SliceAtts = SliceAttributes()\n");
    if(currentAtts != 0)
        s += PySliceAttributes_ToString(currentAtts, "SliceAtts.", true);
    return s;
}

static void
PySliceAttributes_CallLogRoutine(Subject *subj, void *data)
{
    typedef void (*logCallback)(const std::string &);
    logCallback cb = (logCallback)data;

    if(cb != 0)
    {
        std::string s("SliceAtts = SliceAttributes()\n");
        s += PySliceAttributes_ToString(currentAtts, "SliceAtts.", true);
        cb(s);
    }
}

void
PySliceAttributes_StartUp(SliceAttributes *subj, void *data)
{
    if(subj == 0)
        return;

    currentAtts = subj;
    PySliceAttributes_SetDefaults(subj);

    //
    // Create the observer that will be notified when the attributes change.
    //
    if(SliceAttributesObserver == 0)
    {
        SliceAttributesObserver = new ObserverToCallback(subj,
            PySliceAttributes_CallLogRoutine, (void *)data);
    }

}

void
PySliceAttributes_CloseDown()
{
    delete defaultAtts;
    defaultAtts = 0;
    delete SliceAttributesObserver;
    SliceAttributesObserver = 0;
}

PyMethodDef *
PySliceAttributes_GetMethodTable(int *nMethods)
{
    *nMethods = 1;
    return SliceAttributesMethods;
}

bool
PySliceAttributes_Check(PyObject *obj)
{
    return (obj->ob_type == &SliceAttributesType);
}

SliceAttributes *
PySliceAttributes_FromPyObject(PyObject *obj)
{
    SliceAttributesObject *obj2 = (SliceAttributesObject *)obj;
    return obj2->data;
}

PyObject *
PySliceAttributes_New()
{
    return NewSliceAttributes(0);
}

PyObject *
PySliceAttributes_Wrap(const SliceAttributes *attr)
{
    return WrapSliceAttributes(attr);
}

void
PySliceAttributes_SetParent(PyObject *obj, PyObject *parent)
{
    SliceAttributesObject *obj2 = (SliceAttributesObject *)obj;
    obj2->parent = parent;
}

void
PySliceAttributes_SetDefaults(const SliceAttributes *atts)
{
    if(defaultAtts)
        delete defaultAtts;

    defaultAtts = new SliceAttributes(*atts);
}

